package com.jt.tenant.conn;

import com.jt.tenant.app.JTApplication;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@HttpInlet(Conn.INLET_SELECT_OIL_ORDER)
public class GetMyOrder4 extends JTAsyGet<GetMyOrder4.Info> {

//    public String carshop_id;

    public String date;

    public String user_id = JTApplication.jtPreferences.readUserID();

    public String token = JTApplication.jtPreferences.readToken();

    public GetMyOrder4(AsyCallBack<Info> asyCallBack) {

        super(asyCallBack);

//        this.carshop_id = carshop_id;

    }

    @Override
    protected Info parser(JSONObject object) {

        JSONObject apiTYF = object.optJSONObject("apiTYF");

        JSONObject head = apiTYF.optJSONObject("head");

        Info info = new Info();

        info.msg = head.optString("msg");

        JSONObject body = apiTYF.optJSONObject("body");

        JSONArray list = body.optJSONArray("list");

        if(list != null){

            for (int i = 0; i < list.length(); i++) {

                JSONObject object1 = list.optJSONObject(i);

                OrderList list1 = new OrderList();

                list1.GASCODE = object1.optString("gasCode");

                list1.GASAPPOINTMENTTIME = object1.optString("gasAppointmentTime");

                list1.TOTAL = object1.optString("gasTotalMoney");

                list1.DISCOUNT = object1.optString("gasFavorablePrice");

                list1.NUM = object1.optString("gasBoyCount");

                list1.PRICE = object1.optString("gasSalePrice");

                list1.LON = object1.optString("gasLon");

                list1.LAT = object1.optString("gasLat");

                list1.GASSTATE = object1.optString("gasState");

                list1.GASSTATENAME = object1.optString("gasStateName");

                list1.GAS_NAME = object1.optString("gasName");

                list1.GAS_ADDRESS = object1.optString("gasAddress");

                list1.INTEGRALCOUNT = object1.optString("integralCount");

                info.orderLists.add(list1);
            }

        }else{

            TOAST = "当月无加油订单";

        }

        return info;

    }

    public static class Info {

        public String msg;

        public List<OrderList> orderLists = new ArrayList<>();

    }

    public static class OrderList implements Serializable {

        public String GASCODE,GASAPPOINTMENTTIME, TOTAL, NUM, PRICE,LON,LAT,DISCOUNT,GASSTATE,GASSTATENAME,GAS_NAME,GAS_ADDRESS;

        public String INTEGRALCOUNT;

    }



}
